@extends("layouts.common")
@section("content")

    <style>
        .panel .panel-heading .panel-actions {
            float: right;
            margin-right: -15px;
            height: 40px;
            font-size: 0;
            width: 30%;
            text-align: right;
        }
    </style>
    <div class="row">
        <div class="col-lg-12">
            @if (isset($errors) && count($errors) > 0)
                <div class="alert alert-danger alert-dismissible">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <h4><i class="icon fa fa-ban"></i> 错误</h4>
                    <ul>
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            @endif
            @if (Session::has('messages'))
                <div class="alert alert-success alert-dismissible">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <h4><i class="icon fa fa-check"></i> 成功!</h4>
                    <ul>
                        @foreach (Session::get('messages') as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            @endif
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header"><i class="fa fa-table"></i>交易记录</h3>
            <ol class="breadcrumb">
                <li><i class="fa fa-home"></i><a href="/welcome">Home</a></li>
                <li><i class="fa fa-table"></i>交易列表</li>
            </ol>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2><i class="fa fa-indent red"></i><strong>搜索</strong></h2>
                </div>
                <form action="" method="get" class="form-inline">
                    <div class="panel-body">

                        <div class="form-group">
                            <label class="sr-only" for="if-password">姓名</label>
                            <input type="text" id="if-password" name="name" class="form-control" placeholder="姓名">
                        </div>
                        <div class="form-group">
                            <label class="sr-only" for="if-email">Email</label>
                            <input type="text" id="if-email" name="email" class="form-control" placeholder="邮箱">
                        </div>
                        <div class="form-group">
                            <label class="sr-only" for="if-email">Email</label>
                            <input type="text" id="if-ticket" name="ticket" class="form-control" placeholder="交易编号">
                        </div>
                    </div>
                    <div class="panel-footer">
                        <button type="submit" class="btn btn-sm btn-success"><i class="fa fa-dot-circle-o"></i> 搜索</button>
                        <button type="reset" class="btn btn-sm btn-danger"><i class="fa fa-ban"></i> 重置</button>
                    </div>
                </form>
            </div>

        </div>
    </div>

    <div class="row">

        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2><i class="fa fa-table red"></i><span class="break"></span><strong>交易列表</strong></h2>
                    <div class="panel-actions">
                        <a  href="/import" style="cursor:pointer;"><i class="fa  fa-plus"></i>导入交易记录&nbsp;&nbsp;</a>
                    </div>
                </div>
                <div class="panel-body">
                    <table class="table table-condensed">
                        <thead>
                        <tr>
                            <th>交易人</th>
                            <th>邮箱</th>
                            <th>交易编号</th>
                            <th>类型</th>
                            <th>交易品种</th>
                            <th>开始日期</th>
                            <th>结束日期</th>
                            <th>交易佣金</th>
                            <th>隔夜费</th>
                            <th>买入价格</th>
                            <th>卖出价格</th>
                            <th>手数</th>
                            <th>盈亏</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($list as $val)
                            <tr>
                                <td>{{$val->firstname.$val->lastname}}</td>
                                <td>{{$val->uemail}}</td>
                                <td>{{$val->ticket}}</td>
                                <td>{{$val->type}}</td>
                                <td>{{$val->item}}</td>
                                <td>{{$val->starttime}}</td>
                                <td>{{$val->endtime}}</td>
                                <td>{{$val->commission}}</td>
                                <td>{{$val->day_money}}</td>
                                <td>{{$val->startprice}}</td>
                                <td>{{$val->endprice}}</td>
                                <td>{{$val->size}}</td>
                                <td>{{$val->profit}}</td>
                            </tr>
                        @endforeach

                        </tbody>
                    </table>
                    @include("layouts.page",['paginator'=>$list])
                </div>
            </div>
        </div><!--/col-->
    </div>
    <style>
        td,th{
            text-align: center;
        }
    </style>

    <script>
        $(function () {


            var search = location.search.substring(1);
            if (search) {
                try {
                    var query = JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}');

                    $.each(query, function(k, v) {
                        $('[name=' + k + ']').val(v);
                    });
                } catch (e) {
                    console.log(e);
                }

            }
        });
    </script>
@endsection